import count from '@dfeidao/atom-nodejs/db/count';
import query from '@dfeidao/atom-nodejs/db/query';
// import { IBaseTable } from '@feidao/web/atom/nodejs/db/interfaces';

interface Message {
	filter: {
		modelid: object[];
		productid: string;
	};
	page_size: number;
	page_no: number;
}

// 查询数据(模型定义)
export default async function atom(msg: Message, action_id: string, session_id: string) {
	const systemid = '11';
	const { exec, prepare } = query(action_id, session_id, systemid);
	prepare('base_model', ['_id', 'file_cont', 'version', 'modelid', 'diagram_no', 'productid'], msg.filter, msg.page_size, msg.page_no, [], []);
	const [data] = await exec();

	// const c = count(action_id, session_id, spaceid, systemid);
	const { exec: a, prepare: b } = count(action_id, session_id, systemid);
	b('base_model', msg.filter);
	const [t] = await a();

	return { dataArray: data, count: t };
}
